﻿using System;
using System.Collections.Generic;
using System.Linq;
using FrontEnd.Models;

namespace FrontEnd.Application.ContentService.Fake
{
    internal class FakeContentService : IContentService
    {

        #region Fake Data
        
        private static readonly IList<ProposalInfo> FakeProposals =
            new List<ProposalInfo>
            {              
                 new ProposalInfo
                 {                     
                     Name = "TestApple1",
                     Title = "Test Apple #1",
                     Content = "Test Apple Content #1",
                     UserAdds = 150
                 },
                 new ProposalInfo
                 {                       
                     Name = "TestApple2",
                     Title = "Test Apple #2",
                     Content = "Test Apple Content #2",
                     UserAdds = 2
                 }, 							 
                 new ProposalInfo
                 {               
                     Name = "TestMicrosoft1",
                     Title = "Test Microsoft #1",
                     Content = "Test Microsoft Content #1",
                     UserAdds = 145
                 },
                 new ProposalInfo
                 {
                     Name = "TestMicrosoft2",
                     Title = "Test Microsoft #2",
                     Content = "Test Microsoft Content #2",
                     UserAdds = 48
                 }
            };

        #endregion
        
        public IEnumerable<ProposalInfo> EnumerateAvailableProposals()
        {
        	return FakeProposals;
        }

        public int IncrementProposalUserAdds(string proposalName)
        {
			ProposalInfo proposalInfo = FakeProposals
					.FirstOrDefault(prop => prop.Name == proposalName);

			if (proposalInfo != null)
			{
				proposalInfo.UserAdds++;
				return proposalInfo.UserAdds;
			}

            return new Random().Next(255);
        }       
    }
}